package com.ruoyi.netty.handler;

import com.alibaba.fastjson2.JSON;
import com.ruoyi.netty.NettyServer;
import com.ruoyi.netty.Result;
import com.ruoyi.netty.command.ChatMessage;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;

/**
 * @author Zoo
 */
public class CoordinateHandler {

    public static void execute(ChannelHandlerContext ctx, TextWebSocketFrame frame){

        ChatMessage chatMessage = JSON.parseObject(frame.text(), ChatMessage.class);

        System.out.println(frame.text());
        ctx.channel().writeAndFlush(Result.success("1111"));
        ctx.channel().writeAndFlush(Result.success(JSON.toJSONString(NettyServer.USERS.keySet())));
    }
}
